package com.taboa.nettest;

import java.util.concurrent.Executor;

import com.taobao.remoting.RequestProcessor;
import com.taobao.remoting.util.DIYExecutor;

class UpdateCacheRequestProcessor implements RequestProcessor<UpdateCacheRequest> {

	private volatile Cache localCache;

	@Override
	public void handleRequest(UpdateCacheRequest appRequest, AppResponseOutput respOut) {
		localCache = appRequest.getCache();
		System.out.println("Cache updated");

		UpdateCacheResponse response = new UpdateCacheResponse();
		response.setOK(true);
		respOut.write(response);
	}

	@Override
	public Class<UpdateCacheRequest> interest() {
		return UpdateCacheRequest.class;
	}

	@Override
	public Executor getExecutor() {
		return DIYExecutor.getInstance();
	}

	@Override
	public void onRejectedExecutionException(UpdateCacheRequest appRequest, AppResponseOutput respOut) {
	}
}